package com.lolineet.page.result;

import com.github.pagehelper.PageInfo;

/**
 * @Auther lolineet
 * @Email tj.zhanghongwei@163.com
 * @Date 2021/11/24 14:15
 * @Description 分页信息
 */
public class Pagination {
    /**
     * 当前页
     */
    private int current;
    /**
     * 每页的数量
     */
    private int pageSize;
    /**
     * 总页数
     */
    private long total;
    /**
     * 总页数
     */
    private int pages;
    /**
     * 是否到最后的节点
     */
    private boolean leaf;

    public Pagination(int current, int pageSize, long total, int pages) {
        this.current = current > 0 ? current : 1;
        this.pageSize = pageSize;
        this.total = total;
        this.pages = pages;
        this.leaf = current >= pages;
    }

    public Pagination(PageInfo<?> page) {
        this(page.getPageNum(), page.getPageSize(), page.getTotal(), page.getPages());
    }

    public Pagination() {
    }

    public int getCurrent() {
        return current;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public boolean isLeaf() {
        return leaf;
    }

    public void setLeaf(boolean leaf) {
        this.leaf = leaf;
    }

    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }
}
